<template>
    <div ref="list">
        <Row>
            <div class="main-detail">
                <div class="main-content">
                    <p class="message" v-for="(item,index) in list" :key="index" :title="item.title">
                        <a  href="javascript:void(0);"   @click="  localClick(item.infoCode=='1',item.url,item.id,item.infoId)">
                            <span class="dian"></span>
                            <span class="span-Eli" :style="{width:Width+'px'}">
                                 {{item.newsTitle}}
                               </span>
                            <span class="message-timer">{{item.createTime}}</span>
                        </a>
                    </p>
                </div>
            </div>
        </Row>
        <Row>
            <Page class="page-page" :current="current" :total="total" :page-size="size"  size="small" @on-change="changePage" @on-page-size-change="changePageSize" show-total show-elevator show-sizer></Page>
        </Row>
    </div>
</template>

<script>
    import tableDtail from '../component/table-detail'
    import { dateFormat,dateTime } from "@/libs/date";
    import { screenW,onSize,fromPost,downCount,openHref} from "@/libs/tool";
    import  {getNewsByPage} from  '@/api/detail.js'
    export default {
        name: "news-list",
        component:{
            tableDtail
        },
        data(){
            return{
                list:'',
                current:1,
                size:10,
                title:'',
                total:'',
                Width:0,
                screenWidth:screenW(),
            }
        },
        watch:{
            screenWidth (val) {
                this.screenWidth = val
                this.onWidth()
            }
        },
        methods:{
            dateFormat:dateFormat,
            fromSummit:fromPost,
            Download(){
                getNewsByPage({
                    current:this.current,
                    size:this.size,
                    title:this.title
                }).then(res=>{
                    if(res.success){
                        this.total=res.result.total;
                        this.list=res.result.records;
                    }
                })
            },
            changePage(v) {
                this.current = v;
                this.Download();
            },
            changePageSize(v) {
                this.size = v;
                this.Download();
            },
            onWidth(){
                this.Width=this.$refs.list.clientWidth-160;
            },
            localClick(item,url,id,newID){
                if(item){
                    this.setStore('pagesNewsDetail',id)
                    this.$router.push({
                        name: "pages_news_detail"
                    });
                }else {
                    this.fromSummit(url,
                        {
                            authToken: this.accessToken,
                            templateName:'news',
                            infoID:newID.toString()
                        })
                }
            },
        },
        created(){
        },
        mounted(){
            this.Download();
            this.onWidth()//动态的添加宽度为了本页面的省略号才搞的
            onSize(this,'screenWidth')//监听赋值
        }
    }
</script>

<style scoped lang="less">
    @import "./list";
</style>
